package Dome2;

public class Text2 {

    public static void main3(String[] args) {
        fRun(new Robot("1hao"));
    }
    public static void func(Animal animal){
        animal.eat();
    }
    public static void fFly(IFlying flying){
        flying.fly();
    }
    public static void fRun(IRunning running){
        running.run();
    }
    public static void fSwim(ISwimming swimming){
        swimming.swim();
    }

    public static void main(String[] args) {
        fSwim(new Frog("vava",1));
        fRun(new Frog("vava",1));
    }
    public static void main1(String[] args) {
        func(new Cat("mimi",1));
        func(new Frog("vava",1));
        func(new Duck("yaya",1));

    }
}

abstract class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

     public abstract void eat();
}


interface IFlying {
    void fly();
}
interface IRunning {
    void run();
}

interface ISwimming {
    void swim();
}

class Cat extends Animal implements IRunning {
    public Cat(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"吃猫粮");
    }

    @Override
    public void run() {
        System.out.println(this.name + "正在用四条腿跑");
    }

}



class Frog extends Animal implements IRunning, ISwimming {
    public Frog(String name, int age) {
        super(name, age);
    }


    @Override
    public void run() {
        System.out.println(this.name + "正在往前跳");
    }
    @Override
    public void swim() {
        System.out.println(this.name + "正在蹬腿游泳");
    }
    @Override
    public void eat() {
        System.out.println(name+"吃青蛙粮");
    }
}

class Duck extends Animal implements IRunning, ISwimming, IFlying {
    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void fly() {
        System.out.println(this.name + "正在用翅膀飞");
    }

    @Override
    public void run() {
        System.out.println(this.name + "正在用两条腿跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name + "正在漂在水上");
    }
    @Override
    public void eat() {
        System.out.println(name+"吃鸭粮");
    }
}